package cn.felord.memberservice.api;

import cn.felord.memberservice.entity.SysUserInfo;
import cn.felord.memberservice.service.SysUserInfoService;
import com.baomidou.mybatisplus.toolkit.IdWorker;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDateTime;

/**
 * Created with IntelliJ IDEA.
 * Author: Dax
 * Description:
 * Date: 2018/4/1
 * Time: 16:18
 */

@RestController
@RequestMapping("/hi")
public class IndexController {
    @Resource
    private SysUserInfoService sysUserInfoService;

    @RequestMapping("/m")
    public void response() {
        SysUserInfo userInfo = new SysUserInfo();
        userInfo.setUserId(IdWorker.getIdStr());
        userInfo.setUserName("adminA");
        userInfo.setNickName("jackA");
        userInfo.setEmail("felordA@qq.com");
        userInfo.setLoginPassword("admin");
        userInfo.setCrtTime(LocalDateTime.now().toString());

        sysUserInfoService.saveUser(userInfo);
    }

    @RequestMapping("/user/{userId}")
    public SysUserInfo resp(@PathVariable("userId") String userId) {

        return sysUserInfoService.selectUserById(userId);
    }
}
